/**
 * 
 */
package com.nxn.core.model;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "t_resource_menu")
public class ResourceMenu extends IdEntity {
	
	private String name;
    private String displayName;
	private String url;
	private String icon;
	private ResourceMenu parent;
	private Set<ResourceMenu> children;

	
	@Column(name = "name", unique = true, nullable = false)
	public String getName() {
		return name;
	}
	@Column(name="displ_Name")
	public String getDisplayName() {
		return displayName;
	}
	@Column(name="url")
	public String getUrl() {
		return url;
	}
	@Column(name="icon")
	public String getIcon() {
		return icon;
	}
	/**
	 * (定义列名) @JoinColumn与@Column相区别的是：
	 * @JoinColumn注释的是保存表与表之间关系的字段，它要标注在实体属性上。
	 * 而 @Column标注的是表中不包含表关系的字段。
	 */
    @ManyToOne(cascade=CascadeType.MERGE) //多对一的关联
    @JoinColumn(name="parent_id")//这是自关联的pid列名设置
	public ResourceMenu getParent() {
		return parent;
	}
    @OneToMany(mappedBy="parent")//一对多，mappedBy="parent"表示由parent主导（即在parent端有值）
	public Set<ResourceMenu> getChildren() {
		return children;
	}
    
	public void setName(String name) {
		this.name = name;
	}
	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public void setIcon(String icon) {
		this.icon = icon;
	}
	public void setParent(ResourceMenu parent) {
		this.parent = parent;
	}
	public void setChildren(Set<ResourceMenu> children) {
		this.children = children;
	}
	
}